home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Icon / c / FileIcon < prev    next >
Text File  |  1995-07-08  |  2KB  |  62 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Icon.FileIcon.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.01 (26 Jun 1994)
  14.     Purpose: Changes an icon in a window to display the correct filetype
  15.                sprite for the given filetype number.
  16. */
  17.  
  18.  
  19. #include <stdio.h>
  20.  
  21. #include "DeskLib:Wimp.h"
  22. #include "DeskLib:WimpSWIS.h"
  23. #include "DeskLib:Icon.h"
  24.  
  25. void Icon_FileIcon(window_handle window, icon_handle icon, int filetype)
  26. {
  27.   /* Icon should be an indirected text-only icon with enough room in text
  28.      buffer to hold the sprite name.  
  29.      This converts to an indirected sprite-only icon, and fills in the sprite
  30.      name and area.
  31.   */
  32.   icon_createblock iconcreate;
  33.   icon_handle handle;
  34.  
  35.   /* Get the data for this icon */
  36.   Wimp_GetIconState(window, icon, &iconcreate.icondata);
  37.  
  38.   /* Delete this icon - we have to change the data fields */
  39.   Wimp_DeleteIcon(window, icon);
  40.  
  41.   /* Put sprite name in name field */
  42.   sprintf((char *) iconcreate.icondata.data.indirectsprite.name, 
  43.           "file_%03x", filetype);
  44.  
  45.   /* Fill in sprite area */
  46.   iconcreate.icondata.data.indirectsprite.spritearea = (unsigned int *) 1;
  47.  
  48.   /* Fill in sprite name length */
  49.   iconcreate.icondata.data.indirectsprite.nameisname = 8; /* file_xxx */
  50.  
  51.   /* Change to sprite-only */
  52.   iconcreate.icondata.flags.data.text   = FALSE;
  53.   iconcreate.icondata.flags.data.sprite = TRUE;
  54.  
  55.   /* Re-create the icon */
  56.   iconcreate.window = window;
  57.   Wimp_CreateIcon(&iconcreate, &handle);
  58.     
  59.   /* Force the icon to be redrawn */
  60.   Wimp_SetIconState(window, handle, 0, 0);
  61. }
  62.